class State {
    buttonWasPressed() {
        throw new Error( '父类的 buttonWasPressed 方法必须被重写' );
    }
}

export class OffLightState extends State {
    constructor(light) {
        super();
        this.light = light;
    }

    buttonWasPressed() {
        console.log('弱光'); // 对应的行为
		this.light.setState( this.light.weakLightState ); // 切换状态
    }
}

export class WeakLightState extends State {
    constructor(light) {
        super();
        this.light = light;
    }

    buttonWasPressed() {
        console.log('强光'); // 对应的行为
		this.light.setState( this.light.strongLightState ); // 切换状态
    }
}


export class StrongLightState extends State {
    constructor(light) {
        super();
        this.light = light;
    }

    buttonWasPressed() {
        console.log('关灯'); // 对应的行为
		this.light.setState( this.light.offLightState ); // 切换状态
    }
}